<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <!-- 
        NOTE: 使用innerHTML属性创建的<script>元素永远不会执行
     -->

    <!-- 
        <script src="foo.js"></script> 
        以上的代码可以像下面这样使用JavaScript实现
    -->

    <script>
        let script = document.createElement("script")
        script.src = 'foo.js'
        document.body.appendChild(script)
    </script>

    <!-- 
        <script>
            const print = () => {
                console.log('hello')
            }
        </script> 

        以上代码可以这么写
    -->

    <script>
        let script1 = document.createElement("script")
        script1.appendChild(document.createTextNode("const print = () => {console.log('hello')}"))
        document.body.appendChild(script1)

        print() // hello
    </script>
</body>
</html>